﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;
using FJASPX.Service;
using FJASPX.Framwork.UI;
using log4net;
using FJASPX.Framwork.Helper;
using FJASPX.Framwork.Constant;

namespace PlugNT.Cms.Web.Member.Link
{
    public partial class Edit : EditPageBase<FJASPX.Domain.Link>
    {
        public ILinkService iLinkService { get; set; }

        #region Properties属性

        public override string PowerCode
        {
            get { return "51f0cdc42e0a4cdc8290f2e87db79d34"; }
        }

        #endregion

        #region Methods方法

        protected override bool FirstCallRead()
        {
            this.btn_BReturn = this.btn_Return;
            base.FirstCallRead();
            return true;
        }

        #endregion

        #region Events事件

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            if (this.IsUpdate)
            {
                int id = Convert.ToInt32(StringHelper.GetQueryString(Strings.ID));
                this.Model = iLinkService.Get(id);
            }
            else
            {
                this.Model = new FJASPX.Domain.Link();
                this.Model.Creator = this.CurrentUser.UserName;
                this.Model.TimeStamp = DateTime.Now;
                this.Model.UserId = 0;
                this.Model.UserName = this.CurrentUser.UserName;
                this.Model.State = 1;
            }
            this.Model.Name = this.txt_Name.GetValue();
            this.Model.Contant = this.txt_Contant.GetValue();
            this.Model.Url = this.txt_URL.GetValue();
            try
            {
                if (this.Model.Id.IsNull()) 
                    iLinkService.Update(Model);
                else
                    iLinkService.Save(Model);
                //这里加清缓存操作
                this.Success();
                return;
            }
            catch (Exception ex)
            {
                Log.WriteLog(Message.ERR, ex);
            }
            this.Fail();
        }

        #endregion
    }
}